#include<../data_tools/usefull_routines.c>

int main(int argc, char *argv[])
{
  int NTOTAL=0,npart[6],n,i,j;
  double mass[6],masstotal=0.0;
  particulas *diskpart;
  char infiles[1000],*infile;
  infile = argv[1];
  
  for(i=0; i<6; i++)
    {
      NTOTAL = NTOTAL+Header.npartTotal[i];
    }

  diskpart = (particulas *)malloc((size_t)NTOTAL*sizeof(particulas));
  if(diskpart == NULL){
    printf("Allocation error routines:81\n");
    exit(0);
  }
  
  n=0;
  for(j=0; j<6; j++)
    {
      npart[j] = 0;
      mass[j] = 0.0;
      if( (Header.npartTotal[j])!=0 )
	{
	  FILE *diskfile;
	  sprintf(infiles,"%s.%d",infile,j);
	  diskfile = fopen(infiles,"r");
	  npart[j] = contadorParticulas(infiles);
	  
	  for(i=n; i<n+npart[j] ; i++)
	    {
	      fscanf(diskfile,"%d %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",
		     &diskpart[i].id,
		     &diskpart[i].pos[0],&diskpart[i].pos[1],&diskpart[i].pos[2],
		     &diskpart[i].vel[0],&diskpart[i].vel[1],&diskpart[i].vel[2],
		     &diskpart[i].mass,
		     &diskpart[i].pot,
		     &diskpart[i].posc[0],&diskpart[i].posc[1],&diskpart[i].posc[2],
		     &diskpart[i].velc[0],&diskpart[i].velc[1],&diskpart[i].velc[2],
		     &diskpart[i].mang[0],&diskpart[i].mang[1],&diskpart[i].mang[2],
		     &diskpart[i].mr,
		     &diskpart[i].r,
		     &diskpart[i].vc,
		     &diskpart[i].epsilon);
	      mass[j] = mass[j]+diskpart[i].mass;
	    }
	  fclose(diskfile);
	}
      masstotal = masstotal+mass[j];
      n = n + npart[j];
      
      printf("tipo %d with %d particles of mass %e = %e\n",j,npart[j],Header.mass[j],mass[j]);
     
    }
  
  return 0;
}
